package com.qhy.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qhy.pojo.TbUser;
import com.qhy.service.IUserService;

@RequestMapping("user")
@Controller
public class UserController {
	
	
	@Resource
	private IUserService iUserService;
	
	@RequestMapping("queryAll.do")
	public String queryAll(HttpServletRequest request,@RequestParam(defaultValue = "1")Integer tr) {
		PageHelper.startPage(tr,8);
		PageInfo<TbUser> page = new PageInfo<TbUser>(iUserService.query(null));
		request.setAttribute("p", page);
		return "register";
	}
	
	@RequestMapping("deleteById.do")
	public String deleteById(Integer psId) {
		int row = iUserService.deleteById(psId);
		return "forward:/user/queryAll.do";
	}
	
	@RequestMapping("queryByRole.do")
	public String queryByRole(HttpServletRequest request,@RequestParam(defaultValue = "0")Integer tr) {
		PageHelper.startPage(tr,8);
		PageInfo<TbUser> page = new PageInfo<TbUser>(iUserService.queryByRole());
		request.setAttribute("p", page);
		return "realName";
	}
	
	@RequestMapping("passRealName.do")
	public String passRealName(TbUser user) {
		iUserService.passRealName(user);
		return "forward:/user/queryByRole.do";
	}
	
	@RequestMapping("noPassRealName.do")
	public String noPassRealName(TbUser user) {
		iUserService.noPassRealName(user);
		return "forward:/user/queryByRole.do";
	}
	
}
